package ru.stork.vasilisa.model

import ru.stork.vasilisa.lang

object Property {

  import com.wordpress.michid.Memoize._

  private def _fromNode(manager:Namespace, node:lang.Property) = new Property(
    node.name,
    Declaration.fromNode(manager, node.typ),
    node
  )

  val fromNode = memoize(_fromNode _)
}

class Property(val name: String,
               val typ: Type,
               val node: lang.Node) extends NotNull {

  /**
   * Properties equals by name.
   */
  override def equals(that: Any): Boolean = that match {
    case other: Property => name == other.name
    case _ => false
  }
}